package com.example.qxfw.nyqx.service.impl;

import com.example.qxfw.common.entity.ny.CropDistIndex;
import com.example.qxfw.nyqx.mapper.CropDistIndexMapper;
import com.example.qxfw.nyqx.service.CropDistIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Service
public class CropDistIndexServiceImpl implements CropDistIndexService {

    @Autowired
    private CropDistIndexMapper cropDistIndexMapper;

    @Override
    public List<String> getCropName() {
        return cropDistIndexMapper.getCropName();
    }


    @Override
    public List<CropDistIndex> getList(String cropName, String time) {
        return cropDistIndexMapper.selectListByCropName(cropName,time);
    }

    @Override
    public List<CropDistIndex> getList2(String cropName, String time) {
//        return cropDistIndexMapper.selectList(Wrappers.<CropDistIndex>lambdaQuery()
//                .like(CropDistIndex::getCropname,cropName));
        LocalDate parse = LocalDate.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        String time1 = parse.format(DateTimeFormatter.ofPattern("MMdd"));

        return cropDistIndexMapper.selectListLikeCropName(cropName, time1);
    }
}
